package modele;

import java.util.LinkedList;

public class Pousseur extends AbsPiece {

    public Pousseur(String position, int type) {
        super(position, type);
    }

    @Override
    public LinkedList<String> getPossibilite(int[][] region) {
        LinkedList<String> retour = new LinkedList<String>();
        int ligneAct = this.position.charAt(1);
        int colonneAct = this.position.charAt(0);
 
        if(this.type == 2) {
            for(int i = 0; i < region[0].length; i ++) {
                if(region[1][2-i] != 1 && region[1][2-i] != 2 && region[1][2-i] != -1) {
                    if(i == 1 && region[1][1] == 0) 
                        retour.add(this.position + (char)(colonneAct + 1-i) + (char)(ligneAct-1));
                    else if(i != 1)
                        retour.add(this.position + (char)(colonneAct + 1-i) + (char)(ligneAct-1));
                }
            }
        } else {
            for(int i = 0; i < region[1].length; i ++) {
                if(region[0][2-i] != 4 && region[0][2-i] != 3 && region[0][2-i] != -1) {
                    if(i == 1 && region[0][1] == 0) 
                        retour.add(this.position + (char)(colonneAct + 1-i) + (char)(ligneAct+1));
                    else if(i != 1)
                        retour.add(this.position + (char)(colonneAct + 1-i) + (char)(ligneAct+1));
                }
            }
        }
        
        return retour;
    }

}
